<template>
	<view class="u-page">
		<u-list>
			<u-list-item v-for="(item, index) in myFans" :key="item.id">
				<u-cell :title="item.username" @click="goTopage(item.id,item.avatar,item.username)">
					<u-avatar slot="icon" shape="square" size="35" :src="ImgUrl+item.avatar"
						customStyle="margin: -3px 5px -3px 0"></u-avatar>
						<u-icon slot="right-icon" :name="manOrWoman[item.gender]"
						 :color="manOrWomanColor[item.gender]" size="28"
						 customStyle="margin: -3px 35px -3px 0"
						 ></u-icon>
				</u-cell>
			</u-list-item>
		</u-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				myFans: [],
				ImgUrl: '',
				manOrWoman:['woman','man'],
				manOrWomanColor:['#ffaaff','#2979ff']
			}
		},
		onLoad() {
			this.getFans()
			this.ImgUrl = getApp().globalData.ImgUrl
		},
		methods: {
			async getFans(){
				let BaseUrl = getApp().globalData.BaseUrl
				let token = uni.getStorageSync('token')
				await uni.request({
					url:BaseUrl+'/user/followed',
					method:"GET",
					header:{
						'Content-Type': 'application/json',
						'token': token
					},					
					success: (res) => {
						// console.log(res)
						this.myFans = res.data.data
					}
				}) 
			},
			goTopage(userId,originAvatar,username) {
				uni.navigateTo({
					url: '/pages/Personal/Personal?userId=' + userId + '&avatar=' + originAvatar +
						'&username=' + username
				})
			},
		}
	}
</script>

<style>

</style>
